import 'package:bruno/bruno.dart';
import 'package:flutter/material.dart';
import 'package:meal/constant/sizes.dart';
import 'package:meal/ui/draw_under_line.dart';
import 'package:meal/utils/colors.dart';
import 'package:meal/utils/styles.dart';
import 'package:meal/utils/tools.dart';

class MineInfo extends StatefulWidget {
  const MineInfo({Key? key}) : super(key: key);

  @override
  State<MineInfo> createState() => _MineInfoState();
}

class _MineInfoState extends State<MineInfo> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: Colors.white,
      appBar:
          ToolsUtils.getDefaultBrnAppBar('评价详情', actions: ToolsUtils.actions('删除', pressed: () {})),
      body: SingleChildScrollView(
        padding: const EdgeInsets.symmetric(horizontal: Sizes.default20),
        child: Column(
          children: [
            DrawUnderLine(
              color: ColorsUtils.parseColorFromHexString('#D7D7D7'),
              child: Container(
                padding: const EdgeInsets.symmetric(vertical: Sizes.default20),
                child: ListBody(
                  children: [
                    Container(
                      alignment: Alignment.centerLeft,
                      child: Text(
                        '订单编号：12232964103521',
                        style: StylesUtils.customTextStyle(color: ColorsUtils.color333),
                      ),
                    ),
                    Container(
                      margin: const EdgeInsets.symmetric(vertical: Sizes.default20),
                      alignment: Alignment.centerLeft,
                      child: Text(
                        '顾客昵称：z****17',
                        style: StylesUtils.customTextStyle(color: ColorsUtils.color333),
                      ),
                    ),
                    Container(
                      margin: const EdgeInsets.only(bottom: Sizes.default20),
                      alignment: Alignment.centerLeft,
                      child: Text(
                        '顾客地址：北海市海城区四川北路中银大厦C座c503',
                        style: StylesUtils.customTextStyle(color: ColorsUtils.color333),
                      ),
                    ),
                    Container(
                      margin: const EdgeInsets.only(bottom: Sizes.default20),
                      alignment: Alignment.centerLeft,
                      child: Text(
                        '购买商品：口水鸡',
                        style: StylesUtils.customTextStyle(color: ColorsUtils.color333),
                      ),
                    ),
                    Container(
                      alignment: Alignment.centerLeft,
                      child: Text(
                        '配送时间：2023-03-10 12:14:47',
                        style: StylesUtils.customTextStyle(color: ColorsUtils.color333),
                      ),
                    ),
                  ],
                ),
              ),
            ),
            Container(
                alignment: Alignment.centerLeft,
                margin: const EdgeInsets.symmetric(vertical: Sizes.default20),
                child: ListBody(
                  children: [
                    Container(
                      margin: const EdgeInsets.only(bottom: Sizes.default20),
                      alignment: Alignment.centerLeft,
                      child: Text(
                        '配送员：王小品',
                        style: StylesUtils.customTextStyle(color: ColorsUtils.color333),
                      ),
                    ),
                    Container(
                      margin: const EdgeInsets.only(top: Sizes.default20),
                      child: Row(
                        children: [
                          Text(
                            '配送评分：',
                            style: StylesUtils.customTextStyle(color: ColorsUtils.color333),
                          ),
                          BrnRatingStar(
                              count: 5,
                              selectedCount: 4.5,
                              space: 3,
                              canRatingZero: true,
                              starBuilder: (RatingState state) {
                                return buildRating(state);
                              }),
                        ],
                      ),
                    ),
                    Container(
                      margin: const EdgeInsets.only(top: Sizes.default20),
                      alignment: Alignment.centerLeft,
                      child: Row(
                        children: [
                          Text(
                            '评价内容：服务好，配送快，速度一流！',
                            style: StylesUtils.customTextStyle(color: ColorsUtils.color333),
                          ),
                          Container(
                            constraints: const BoxConstraints.expand(
                                width: Sizes.default40, height: Sizes.default20),
                            alignment: Alignment.center,
                            decoration: BoxDecoration(
                                border: Border.all(color: ColorsUtils.rgba(204, 0, 0, 1)),
                                color: ColorsUtils.rgba(255, 255, 255, 1),
                                borderRadius: BorderRadius.circular(Sizes.default2)),
                            child: Text(
                              '审核中',
                              style: StylesUtils.customTextStyle(
                                  fontSize: Sizes.default12, color: ColorsUtils.colorCc0),
                            ),
                          )
                        ],
                      ),
                    ),
                    Container(
                      margin: const EdgeInsets.only(top: Sizes.default20),
                      alignment: Alignment.centerLeft,
                      child: Text(
                        '评价时间：2023-05-18 12:10:17',
                        style: StylesUtils.customTextStyle(color: ColorsUtils.color333),
                      ),
                    ),
                  ],
                )),
          ],
        ),
      ),
    );
  }

  Widget buildRating(RatingState state) {
    switch (state) {
      case RatingState.select:
        return BrunoTools.getAssetSizeImage(BrnAsset.iconStar, Sizes.default15, Sizes.default15,
            color: ColorsUtils.parseColorFromHexString(ColorsUtils.colorFf6));
      case RatingState.half:
        return BrunoTools.getAssetSizeImage(BrnAsset.iconStarHalf, Sizes.default15, Sizes.default15,
            color: ColorsUtils.parseColorFromHexString(ColorsUtils.colorFf6));
      case RatingState.unselect:
      default:
        return BrunoTools.getAssetSizeImage(BrnAsset.iconStar, Sizes.default15, Sizes.default15,
            color: ColorsUtils.parseColorFromHexString('#A6A6A6'));
    }
  }
}
